<?php
namespace TpAmisAdmin\Admin;

use think\App;
use think\facade\Middleware;
use think\facade\Route;
use think\Service as ThinkService;
use TpAmisAdmin\Admin\middleware\AdminAuthTokenMiddleware;
use TpAmisAdmin\Admin\middleware\Auth;
use TpAmisAdmin\Admin\middleware\CrossDomain;

class Service extends ThinkService
{
    private $commands = [];
    public function boot()
    {
        // 注册命令行
        $this->commands([
            \TpAmisAdmin\Admin\command\BuildCrud::class, // 这里填写你的命令类的完整命名空间
        ]);

        Route::group('test', function () {
            // 注册路由
            Route::get('hello', function () {
                return 'Hello, ThinkPHP 6!';
            });
        });

        Route::post('admin/user/login', 'TpAmisAdmin\Admin\controller\Login@login');
        Route::group('admin', function () {
            Route::get('index', 'TpAmisAdmin\Admin\controller\Index@index');
            Route::post('index', 'app\controller\UserController@createUser');
        })->middleware(AdminAuthTokenMiddleware::class);


        // 全局中间件注册
        // Middleware::add(Auth::class);
        Middleware::add(CrossDomain::class);
    }
}